package com.kitty.web.controller;

import com.kitty.web.controller.BaseController;
import com.kitty.web.common.AjaxResult;
import com.kitty.web.core.page.TableDataInfo;
import com.kitty.web.domain.PRechargescorereward;
import com.kitty.web.system.rechargescorereward.service.IPRechargescorerewardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 积分商城Controller
 * 
 * @author soul
 * @date 2022-03-16
 */
@Controller
@RequestMapping("/system/rechargescorereward")
public class PRechargescorerewardController extends BaseController
{
    private String prefix = "system/rechargescorereward";

    @Autowired
    private IPRechargescorerewardService pRechargescorerewardService;


    @GetMapping()
    public String rechargescorereward()
    {
        return prefix + "/rechargescorereward";
    }

    /**
     * 查询积分商城列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PRechargescorereward pRechargescorereward)
    {
        startPage();
        List<PRechargescorereward> list = pRechargescorerewardService.selectPRechargescorerewardList(pRechargescorereward);
        return getDataTable(list);
    }


    /**
     * 新增积分商城
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存积分商城
     */

    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PRechargescorereward pRechargescorereward)
    {
        return toAjax(pRechargescorerewardService.insertPRechargescorereward(pRechargescorereward));
    }

    /**
     * 修改积分商城
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        PRechargescorereward pRechargescorereward = pRechargescorerewardService.selectPRechargescorerewardById(id);
        mmap.put("pRechargescorereward", pRechargescorereward);
        return prefix + "/edit";
    }

    /**
     * 修改保存积分商城
     */

    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PRechargescorereward pRechargescorereward)
    {
        return toAjax(pRechargescorerewardService.updatePRechargescorereward(pRechargescorereward));
    }

    /**
     * 删除积分商城
     */

    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(pRechargescorerewardService.deletePRechargescorerewardByIds(ids));
    }
}
